package yl.hs.bmipfull.daos.finance;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import yl.hs.bmipfull.daos.BaseDao;
import yl.hs.bmipfull.pojo.comments.SearchDataCate;
import yl.hs.bmipfull.pojo.finance.ContractAmount;
import yl.hs.bmipfull.pojo.finance.ReceiptSettleMainEntity;
import yl.hs.bmipfull.pojo.material.PurchaseContractEntity;
import yl.hs.bmipfull.pojo.material.PurchaseContractPriceAdjustmentEntity;
import yl.hs.bmipfull.pojo.material.PurchaseContractProductEntity;
import yl.hs.bmipfull.pojo.material.PurchaseReceiptEntity;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * IReceiveSettleMainDao
 * @category
 * @author 谢景广
 * @date 2022-01-17
 */
@Repository
public interface IReceiptSettleMainDao extends BaseDao<ReceiptSettleMainEntity> {
    Integer queryDataCountByPage(@Param("map") Map<String, Object> query, List<Map<String, Object>> filters);

    /**
     * 获取状态为1，10的采购合同编号
     * @return
     */
    Integer queryContractSettleLastVerification();

    List<ReceiptSettleMainEntity> queryPage(@Param("map") Map<String, Object> query, List<Map<String, Object>> filters);

    List<PurchaseReceiptEntity> queryTempSettleOrders(@Param("map") Map<String, Object> query,List<Map<String, Object>> filters);

    List<PurchaseContractEntity> querySettleContract(@Param("map") Map<String, Object> query,List<Map<String, Object>> filters);

    List<PurchaseContractProductEntity> querySettleContractDetails(@Param("map") Map<String, Object> query,List<Map<String, Object>> filters);


    List<ReceiptSettleMainEntity> queryContractSettleLast(@Param("map") Map<String, Object> query,List<Map<String, Object>> filters);

    List<ReceiptSettleMainEntity> queryContractLastSettle(@Param("snList") List<String> snList);

    List<ContractAmount> queryContractPayedAmount(@Param("map") Map<String, Object> query,List<Map<String, Object>> filters);

    Integer deleteBySettleSN(String settleSN);

    Integer changeOrderToUnSettle(@Param("snList") List<String> snList);

    Integer changeOrderToSettled(@Param("snList") List<String> snList);

    List<PurchaseContractPriceAdjustmentEntity> querySettleContractAdjust(@Param("map") Map<String, Object> query,List<Map<String, Object>> filters);

    List<PurchaseReceiptEntity> querySettleOrdersBySettleSN(String settleSN);
    @Select("select COALESCE(SUM(currentAmount),0) from receipt_settle_main WHERE state>=0")
    BigDecimal getSumCurrentAmount();

    BigDecimal getSumCurrentAmountByContractSN(@Param("snArray") String[] snArray);

    List<SearchDataCate> penceRate();
    List<SearchDataCate> supplier();

    List<ReceiptSettleMainEntity> getAll();

    ReceiptSettleMainEntity getLastSettle(String contractSN);
    Integer changeOrderToSettledForSNList(List<String> snList);
}
